/************************************************************************
                        Triangles.h - Copyright Claudio Botta

This library is free software; you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or 
(at your option) any later version.
This library is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public License 
along with this library; if not, write to the 
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 
Boston, MA 02110, USA

This file was generated on Sam Mär 15 2008 at 10:58:12
The original location of this file is geomagick/Triangles.h
**************************************************************************/


#ifndef TRIANGLES_H
#define TRIANGLES_H
#include "MeshType.h"

#include <vector>
#include <string>

namespace geomagick{

/**
  * \class Triangle
  * \brief Class to represent a Triangle, used in  Triangles.
  */

class Triangle
{
	public:
	std::vector<int> Vertices;
	std::vector<int> Normals;
	std::vector<int> TextureCoordinates;
	// !TODO EXTEND ME!
};



/**
  * \class Triangles
  * \brief A BaseType to represent Triangulated Meshes.
  */

class Triangles : public MeshType
{
public:

  // Constructors/Destructors
  Triangles(){
	this->TriangleList = boost::shared_ptr<vector<Triangle> >(new vector<Triangle>);
	this->VertexCoordinates = boost::shared_ptr<vector<Vector3d> >(new vector<Vector3d>);
	this->Normals = boost::shared_ptr<vector<Vector3d> >(new vector<Vector3d>);
	this->TextureCoordinates = boost::shared_ptr<vector<Vector2d> >(new vector<Vector2d>);
 }
 
 ~Triangles(){

	if(this->TriangleList.use_count() <= 1) delete this->TriangleList.get();
	else this->TriangleList.reset();
	
	if(this->VertexCoordinates.use_count() <= 1) delete this->VertexCoordinates.get();
	else this->VertexCoordinates.reset();

	if(this->Normals.use_count() <= 1) delete this->Normals.get();
	else this->Normals.reset();

	if(this->TextureCoordinates.use_count() <= 1) delete this->TextureCoordinates.get();
	else this->TextureCoordinates.reset();

	}

  // Static Public attributes
  //  

  // Public attributes
  //  


  // Public attribute accessor methods
  //  


  // Public attribute accessor methods
  //  


protected:

  // Static Protected attributes
  //  

  // Protected attributes
  //  

public:


  // Protected attribute accessor methods
  //  

protected:

public:


  // Protected attribute accessor methods
  //  

protected:


private:

  // Static Private attributes
  //  

  // Private attributes
  //  
 	boost::shared_ptr<vector<Triangle> > TriangleList; 
	boost::shared_ptr<vector<Vector3d> > VertexCoordinates;
	boost::shared_ptr<vector<Vector3d> > Normals;
	boost::shared_ptr<vector<Vector2d> > TextureCoordinates;


public:


  // Private attribute accessor methods
  //  

private:

public:


  // Private attribute accessor methods
  //  
/**
* @return the Normal-Vectors, if the Model has any. If the model doesnt have
*	  Normal-Vectors the boost::shared_ptr<vector<Vector3d> > points to an
*	  empty std::vector<Vector3d> (Not a NULL pointer!).
*
*
**/
boost::shared_ptr<vector<Vector3d> > getNormals(){
		return (this->Normals);
	}


/**
* @return the TextureCoordinates-Vectors, if the Model has any. If the model doesnt have any
*	  TextureCoordinates-Vectors the boost::shared_ptr<vector<Vector2d> > points to an
*	  empty std::vector<Vector2d> (Not a NULL pointer!).
*
*
**/
boost::shared_ptr<vector<Vector2d> > getTextureCoordinates(){
		return (this->TextureCoordinates);
	}



/**
* @return the Vertex-Coordinates, if the Model has any. If the model doesnt have
*	  Vertex-Coordinates the boost::shared_ptr<vector<Vector3d> > points to an
*	  empty std::vector<Vector3d> (Not a NULL pointer!).
*
*
**/
boost::shared_ptr<vector<Vector3d> >getVertexCoordinates(){
		return (this->VertexCoordinates);
	}

/**
* @return the TriangleList. After Construction of Triangles, the
*	  TriangleList is an empty std::vector<Triangle>.
*
*
**/
boost::shared_ptr<vector<Triangle> > getTriangleList(){
		return (this->TriangleList);
	}


/*
boost::shared_ptr<vector<Vector3d> > getNormals(){
		return (this->Normals);
	}

  vector<Vector3d>* getVertexCoordinates(){
		return (this->VertexCoordinates.get());
	}

  vector<Triangle>* getTriangleList(){
		return (this->TriangleList.get());
	}
*/
/**
* @brief Add a Triangle to the Triangle-Mesh
* @return nothing
*/
  void addTriangle(Triangle& newTriangle){
		// !TODO Some integrity checks
		TriangleList->push_back(newTriangle);
	}
 /**
  * @brief add one VertexCoorinates Vector. The value is appended to the End of a Vector Containing all VertexCoords. The order in which VertexCoordinates are added is thus relevant.
  * @return nothing
  * @param VertexCoords the VertexCoordinates. The VertexCoorrdinates describe
  * 			the Coordinates of a MeshVertex. Mesh VertexCoordinates are
  * 			referenced by the  std::vector<int> geomagick::Triangle::Vertices.
  *			Each int i contained in std::vector<int> geomagick::Triangle::Vertices
  *			references the VertexCoords object of Triangles::VertexCoordinates->at(i).
  *			The VertexCoordinates object can be retrieved by the use of 
  *			Triangles::getVertexCoordinates().
*/
  void addVertexCoordinates(Vector3d& VertexCoords){
		// !TODO Some integrity checks
		VertexCoordinates->push_back(VertexCoords);
	}

/**
  * @brief add one Normals Vector to the Model. The value is appended to the End of a Vector Containing all Normals. The order in which Normals are added is thus relevant.
  * @return nothing
  * @param newNormals the Normal Vector to be added. The Normal Vectors describe
  * 			the Direction of the Surface Normal at a MeshVertex. Normal Vectors are
  * 			referenced by the  std::vector<int> geomagick::Triangle::Normals.
  *			Each int i contained in std::vector<int> geomagick::Triangle::Normals
  *			references the VertexCoords object of Triangles::Normals->at(i).
  *			The Normals object can be retrieved by the use of 
  *			Triangles::getNormals().
*/
  void addNormal(Vector3d& newNormals){
		Normals->push_back(newNormals);
	}

/**
  * @brief add one TextureCoordinates Vector to the Model. The value is appended to the End of a Vector Containing all TextureCoordinates. The order in which TextureCoordinates are added is thus relevant.
  * @return nothing
  * @param newTextureCoordinates the Texture-Coordinates Vector to be added. The Texture-Coordinates Vectors describe the what part of the textureis anchored to given MeshVertex. TextureCoordinates are
  * 			referenced by the  std::vector<int> geomagick::Triangle::TextureCoordinates.
  *			Each int i contained in std::vector<int> geomagick::Triangle::TextureCoordinates.
  *			references the VertexCoords object of Triangles::TextureCoordinates->at(i).
  *			The Normals object can be retrieved by the use of 
  *			Triangles::getTextureCoordinates().
*/
  void addTextureCoordinates(Vector2d& newTextureCoordinates){
		TextureCoordinates->push_back(newTextureCoordinates);
	}
 

virtual void printName()
{
        cout << "Triangles\n";
}
static  BaseType* init()
{
        return new Triangles;
}
static string getTypeName()
{
        return "Triangles";
}
static BaseTypeId* getTypeId()
{
        BaseTypeId* newBaseTypeId = new BaseTypeId;
        newBaseTypeId->getTypeName = Triangles::getTypeName;
        newBaseTypeId->init = Triangles::init;
        return newBaseTypeId;
}

void printStatistic()
{
	cout << "Number of Triangles: " << this->TriangleList->size() << endl;
	cout << "Number of Vertices: " << this->VertexCoordinates->size() << endl;
}

private:



};
}
#endif // TRIANGLES_H
